package cn.chl.controller;

import cn.chl.domain.Floor;
import cn.chl.result.JSONResult;
import cn.chl.service.IFloorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/floor")
@RefreshScope // 动态刷新配置注解
public class FloorController {

    @Autowired
    private IFloorService floorService;

    /**
     * 查询单个对象
     */
    @GetMapping("/getOne/{id}")
    public Floor getOne(@PathVariable("id")Integer id){
        return floorService.getOne(id);
    }

    /**
     * 添加数据
     */
    @PostMapping("/add")
    public JSONResult add(@RequestBody Floor floor){
        floorService.add(floor);
        return new JSONResult(true,"添加成功");
    }
}
